<?php
require_once('BaseDAO.php');

class PaypalDAO extends BaseDAO
{
    const PAYPAL_LOG = "paypal_log";
    const PURCHASES = "purchases";

    public function addPayPalLog($log)
    {
        $this->addItem(self::PAYPAL_LOG, $log);
    }

    public function addPurchase($purchase)
    {
        $this->addItem(self::PURCHASES, $purchase);
    }

    public function updatePurchase($purchase, $invoice)
    {
        $trasaction_id = $purchase["trasaction_id"];
        $paypal_log_id = $purchase["log_id"];
        $payment_status = $purchase["payment_status"];

        $sql = "UPDATE `purchases` SET `trasaction_id` = '$trasaction_id ', `log_id` = '$paypal_log_id', `payment_status` = '$payment_status' WHERE `invoice` = '$invoice'";
        return $this->executeQuery($sql);
    }

    public function getPayPalLog($txId)
    {
        $sql = "SELECT * FROM `paypal_log` WHERE `txn_id` = '$txId'";
        return $this->executeQuery($sql);
    }

    public function updatePayPalLog($logArray, $txId)
    {
        $sql = "UPDATE `paypal_log` SET `log` = '$logArray' WHERE `txn_id` = '$txId'";
        return $this->executeQuery($sql);
    }
}

?>